<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="pageContent">
	<form method="post" id="pushForm" action="${rootUrl}/info/push-message/${pushMessage.id}" class="pageForm required-validate" onsubmit="return beforeSubmit(this);">
		 <c:if test="${pushMessage.id != 0 && pushMessage.id != '' }"><input type="hidden" name="_method" value="put"></c:if>
		<input type="hidden" id="pushMessageId" name="pushMessage.id" value="${pushMessage.id }"> 
		<div class="pageFormContent" layoutH="56">
			<p>
			     <label>消息标题：</label>
				<input name="pushMessage.title" class="required" type="text" size="30" value="${pushMessage.title}" />
			</p>
			<p>
			     <label>消息链接：</label>
				<input name="pushMessage.url"  type="text" size="30" value="${pushMessage.url}" />
			</p>
			<dl class="nowrap">
				<dt>消息内容：</dt>
				<dd><textarea name="pushMessage.content" cols="90" rows="5">${pushMessage.content}</textarea></dd>
			</dl>
			<p>
				<label>消息状态：</label>
				<select name="pushMessage.state" class="required combox">
				 <option <c:if test="${pushMessage.state == 0}">selected="selected"</c:if> value="0">未发送</option>
				 <option <c:if test="${pushMessage.state == 1}">selected="selected"</c:if> value="1">已发送</option>
				</select>
			</p>
			<p>
				<label>消息发送时间：</label>
				<input type="text" id="pushtime" name="pushMessage.time" class="date" readonly="readonly" size="30" dateFmt="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${pushMessage.time}" pattern="yyyy-MM-dd HH:mm:ss"/>" /><a class="inputDateButton" href="javascript:;">选择</a>
			</p>
   		 </div>
    	<div class="formBar">
			<ul>
				<li><div id= "pushButton"><div class="buttonContent"><button onclick ="checkPushEndTime()" type="button">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
    </form>
    </div>
    <script>
var myDate = new Date();
var currentTime = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate()+" "+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds();
var pTime=$("#pushtime").val();
var result = (Date.parse(pTime) - Date.parse(currentTime)) / 3600 / 1000;
 $(function(){
	 if($("#pushMessageId").val() == ""){
	    $("#pushButton").attr("class","buttonActive");
	 }else{
    if(result<0){
    	$("#pushButton").attr("class","buttonDisabled");
    }else if(result>=0){
    	$("#pushButton").attr("class","buttonActive");
    }}
}); 
function checkPushEndTime(){
	if($("#pushMessageId").val() == ""||result>=0){
	$("#pushForm").submit();
	}
}
function beforeSubmit(obj){
	return validateCallback(obj, newDialogAjaxDone);
} 
</script>